import pymysql
class DB:
    def __init__(self):
        self.conn = pymysql.connect(host='localhost',port=3306,database='day17',user='root',password='root',cursorclass=pymysql.cursors.DictCursor,charset='utf8')
        self.cousor = self.conn.cursor()


    def findall(self,sql):
        self.cousor.execute(sql)
        return self.cousor.fetchall()

    def findone(self,sql):
        self.cousor.execute(sql)
        return self.cousor.fetchone()

    def insert(self,sql):
        self.cousor.execute(sql)
        return self.conn.commit()

    def close(self):
        self.cousor.close()
        self.conn.close()
db = DB()